/*
 * perspective_camera.h
 *
 *  Created on: 19-jun-2009
 *      Author: HPK
 */

#ifndef PERSPECTIVE_CAMERA_H_
#define PERSPECTIVE_CAMERA_H_

#include "camera.h"
#include "model/frustum.h"

class PerspectiveCamera : public Camera{
	protected:
		Frustum frustum;
		// Repite la definicion del frustum,
		// se almacena dos veces para no
		// tener que recalcularlo en cada frame
		float _fovUp;
		float _aspect;
		float _dNear;
		float _dFar;

	public:
		// fovUp se indica en grados
		PerspectiveCamera(Point eye,Point at,Point up,float fovUp,float aspect,float dNear,float dFar);
		virtual ~PerspectiveCamera();

		virtual void applyCamera();

		virtual bool isBoxVisible(const Cube& box)const{
			return (frustum.intersect(box));
		}

		virtual void moveTo(const Point& p)=0;
		virtual void move(float offset)=0;
		virtual void rotateUD(float theta)=0;
		virtual void rotateLR(float theta)=0;

		virtual void addZoom(float factor);

		virtual Point getAt(){
			return frustum.getAt();
		}
		virtual Point getEye(){
			return frustum.getEye();
		}
		virtual Point getUp(){
			return frustum.getUp();
		}

		const Frustum& getFrustum()const{ return frustum; }

		virtual void updatePosition(const Point& position,const Point& direction,PathInfo* info)=0;

	protected:
		virtual void applyModelViewTransformations()=0;
};

#endif /* PERSPECTIVE_CAMERA_H_ */
